package com.wang.domain;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 同时配置3种初始化+销毁的方法，先执行JSR250，在执行InitializingBean和DisposableBean接口实现的方法，再执行自定义方法
 *
 * @Author wly
 * @Date 2018/7/10 16:41
 */
public class InitDestory4 implements InitializingBean, DisposableBean {
    public InitDestory4() {
        System.out.println("InitDestory4构造函数");
    }

    public void customInit() {
        System.out.println("InitDestory4自定义init()");
    }

    public void customDestory() {
        System.out.println("InitDestory4自定义destory()");
    }

    @PostConstruct
    public void jsr250Init() {
        System.out.println("InitDestory4 jsr250初始化");
    }

    @PreDestroy
    public void jsr250Destory() {
        System.out.println("InitDestory4 jsr250销毁");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("InitDestory4  execute DisposableBean.destory()");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitDestory4  execute InitializingBean.afterPropertiesSet()");
    }
}
